<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html class=""><head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <meta charset="utf-8">
        <title>NutriWeb - Praticando alimentação saudável</title>

        <meta class="viewport" name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">

        <!-- Favicon -->
        <link rel="shortcut icon" href="a_data/icone_nutriweb.ico">
        <!-- Font -->
        <link rel="stylesheet" href="arquivos_arquivos/css.css">
        <!-- Plagins CSS -->
        <link rel="stylesheet" href="arquivos_arquivos/buttons.css">
        <link rel="stylesheet" href="arquivos_arquivos/social-icons.css">
        <link rel="stylesheet" href="arquivos_arquivos/font-awesome.css">
        <link rel="stylesheet" href="arquivos_arquivos/bootstrap.css">
        <link rel="stylesheet" href="arquivos_arquivos/jslider.css">
        <link rel="stylesheet" href="arquivos_arquivos/settings.css">
        <link rel="stylesheet" href="arquivos_arquivos/jquery.css">
        <link rel="stylesheet" href="arquivos_arquivos/animate.css">
        <link rel="stylesheet" href="arquivos_arquivos/video-js.css">
        <link rel="stylesheet" href="arquivos_arquivos/morris.css">
        <link rel="stylesheet" href="arquivos_arquivos/royalslider.css">
        <link rel="stylesheet" href="arquivos_arquivos/rs-minimal-white.css">
        <link rel="stylesheet" href="arquivos_arquivos/layerslider.css">
        <link rel="stylesheet" href="arquivos_arquivos/ladda.css">
        <link rel="stylesheet" href="arquivos_arquivos/datepicker.css">
        <link rel="stylesheet" href="arquivos_arquivos/jquery_002.css">
        <!-- Theme CSS -->
        <link rel="stylesheet" href="a_data/style.css">
        <!-- Responsive CSS -->
        <link rel="stylesheet" href="a_data/responsive.css">
        <!-- Custom CSS -->
        <link rel="stylesheet" href="a_data/pages.css">
        <link rel="stylesheet" href="a_data/home-pages-customizer.css">
        <!-- IE Styles-->
        <link rel="stylesheet" href="a_data/ie.css">
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
          <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
              <link rel='stylesheet' href="css/ie/ie8.css">
        <![endif]-->
        <style type="text/css">
            .jqstooltip { position: absolute;left: 0px;top: 0px;visibility: hidden;background: rgb(0, 0, 0) transparent;background-color: rgba(0,0,0,0.6);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)";color: white;font: 10px arial, san serif;text-align: left;white-space: nowrap;padding: 5px;border: 1px solid white;z-index: 10000;}.jqsfield { color: white;font: 10px arial, san serif;text-align: left;}</style>
        <style type="text/css">.fancybox-margin{margin-right:19px;}</style>
        <script style="" src="arquivos_arquivos/commonutilstats.js" charset="UTF-8" type="text/javascript"></script>
    </head>
    <body class="fixed-header loaded fixed">
        <script type="text/javascript">
            var offset = 0;
            function consultarAlimento(set_offset) {
                var xmlHttp;

                var container = document.getElementById('alimentosList');
                var buttonsDiv = document.getElementById('buttonsDiv');

                offset += set_offset;

                var nm_alimento = document.getElementById('nomeAlimento').value;

                try
                {
                    // Firefox, Opera 8.0+, Safari
                    xmlHttp = new XMLHttpRequest();
                }
                catch (e)
                {
                    // Internet Explorer
                    try
                    {
                        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
                    }
                    catch (e)
                    {
                        try
                        {
                            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                        }
                        catch (e)
                        {
                            alert("O seu navegador não suporta AJAX!");
                            return false;
                        }
                    }
                }
                xmlHttp.onreadystatechange = function ()
                {
                    if (xmlHttp.readyState == 4) //previous.insertAdjacentHTML('afterend', );
                    {
                        var showdata = xmlHttp.responseText;
                        var str = showdata.split("$");
                        var len = str.length;
                        var content = "";
                        var count = 0;
                        var i = 0;
                        for (i = 0; i < len; ) {
                            content += str[i];
                            count = parseInt(str[i + 1]);
                            i = i + 2;
                        }
                        container.innerHTML = content;

                        if (offset > 0 && count > 9) {
                            buttonsDiv.innerHTML = "<button type=\"submit\" class=\"btn btn-default\" onclick=\"consultarAlimento(-10);\">Anterior</button>&nbsp;&nbsp;<button type=\"submit\" class=\"btn btn-default\" onclick=\"consultarAlimento(10);\">Próximo</button>";
                        } else if (offset > 0) {
                            buttonsDiv.innerHTML = "<button type=\"submit\" class=\"btn btn-default\" onclick=\"consultarAlimento(-10);\">Anterior</button>";
                        } else if (count > 9) {
                            buttonsDiv.innerHTML = "<button type=\"submit\" class=\"btn btn-default\" onclick=\"consultarAlimento(10);\">Próximo</button>";
                        } else {
                            buttonsDiv.innerHTML = "";
                        }
                        
                        document.getElementById('pesquisar_btn').disabled = false;
                    }
                }
                var url = "<%=request.getContextPath()%>/jsp/ConsultaAlimento.jsp?nm_alimento="+nm_alimento+"&offset="+offset;
                xmlHttp.open("GET", url, true);
                xmlHttp.send(null);
            }
            function excluirAlimento(cd_alimento) {
                var xmlHttp;

                try
                {
                    // Firefox, Opera 8.0+, Safari
                    xmlHttp = new XMLHttpRequest();
                }
                catch (e)
                {
                    // Internet Explorer
                    try
                    {
                        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
                    }
                    catch (e)
                    {
                        try
                        {
                            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                        }
                        catch (e)
                        {
                            alert("O seu navegador não suporta AJAX!");
                            return false;
                        }
                    }
                }
                xmlHttp.onreadystatechange = function ()
                {
                    if (xmlHttp.readyState == 4) //previous.insertAdjacentHTML('afterend', );
                    {
                        consultarAlimento(0);
                    }
                }
                var url = "<%=request.getContextPath()%>/jsp/ExcluiAlimento.jsp?cd_alimento="+cd_alimento;
                xmlHttp.open("GET", url, true);
                xmlHttp.send(null);
            }
        </script>
        <div class="page-box">
            <div class="page-box-content">
                <%@include file="/templates/header.jsp"%>  
                <div class="breadcrumb-box">
                    <div class="container">
                        <ul class="breadcrumb">
                            <li><a href="inicio.jsp">Início</a> </li>
                            <li><a href="#">Alimento</a> </li>
                            <li class="active">Consultar</li>
                        </ul>	
                    </div>
                </div>
                <%@include file="/templates/welcome.jsp"%>
                <div class="clearfix"></div>

                <section id="main">
                    <header class="page-header">
                        <div class="container">
                            <h1 class="title">Consultar Alimento</h1>
                        </div>	
                    </header>

                    <div class="container">
                        <div class="panel-group" id="accordion3">


                            <div class="row">
                                <div class="col-sm-4  bottom-padding">
                                    <div class="pricing"> 
                                        <h3 class="title" align="center">Alimento</h3>
                                        &nbsp;<label align="center">Nome:</label>
                                        <input class="form-control" id="nomeAlimento" type="text" maxlength="50"></input>
                                        <div align="center" class="buttons-box clearfix">
                                            <button type="submit" id="pesquisar_btn" class="btn btn-default" onclick="consultarAlimento(0); this.disabled = true;">Pesquisar</button>
                                        </div><!-- .buttons-box -->
                                    </div>
                                    <!-- .pricing --> 
                                </div>

                                <div class="col-sm-7  bottom-padding"> 

                                    <!--descrição do aimentoem texto-->
                                    <table class="table table-striped text-left order-details ">
                                        <thead>
                                            <tr>
                                                <th class="product-name">Alimento</th>
                                                <th class="product-total">Quantidade </th>
                                                <th class="product-total">Equivalência</th>
                                                    <% if (session.getAttribute("ic_admin") != null && session.getAttribute("ic_admin").toString().equals("true")) {%>
                                                <th class="product-total">&nbsp;</th>
                                                    <% }%>
                                            </tr>
                                        </thead>
                                        <tbody id="alimentosList">

                                        </tbody>

                                    </table>
                                    <div align="right" class="buttons-box clearfix" id="buttonsDiv">

                                    </div><!-- .buttons-box -->
                                </div>

                                <!--descrição do aimento e porção-->

                            </div>

                        </div>


                    </div>
                </section><!-- #main -->

            </div><!-- .page-box-content -->
        </div><!-- .page-box -->
        <%@include file="/templates/footer.jsp"%> 
        <div class="clearfix"></div>

        <script async="" src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/www-widgetapi.js" id="www-widgetapi-script"></script><script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/iframe_api"></script><script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_015.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/bootstrap.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jshashtable-2.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_018.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/tmpl.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_012.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/draggable-0.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_021.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_016.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_022.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_009.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_019.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_011.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_007.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_008.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_005.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/isotope.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_006.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_017.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_020.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_003.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_013.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/SmoothScroll.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/country.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/spin.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/ladda.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/masonry.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/morris.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/raphael.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/video.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/pixastic.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/livicons-1.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/greensock.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/layerslider_002.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/layerslider.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_014.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_004.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/bootstrapValidator.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/bootstrap-datepicker.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_010.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jplayer.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_002.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/main.js"></script>


        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/js" type="text/javascript"></script><script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/main_002.js"></script>
        <script type="text/javascript">window.onload = function () {
                                                        consultarAlimento(0);
                                                    }</script>
    </body>  
</html>
